#include "Sound.h"
#include "SoundManager.h"

using namespace GalliumEngine;

Sound::Sound(void)
{
	id = "MISSING";
}

Sound::Sound(std::string _id)
{
	id = _id;
}

Sound::~Sound()
{
}

void Sound::playSound()
{
	SoundManager::getInstance()->getSystem()->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
}

void Sound::pauseSound()
{
	channel->setPaused(true);
}

void Sound::resumeSound()
{
	channel->setPaused(false);
}

void Sound::setSound(FMOD::Sound* _sound)
{
	sound = _sound;
}

FMOD::Sound* Sound::getSound()
{
	return sound;
}

void Sound::setPosition(Vector3 position, Vector3 velocity)
{
	FMOD_VECTOR pos = { position[0], position[1], position[2] };
	FMOD_VECTOR vel = { velocity[0], velocity[1], velocity[2] };

	channel->set3DAttributes(&pos,&vel);
}

void Sound::setMinMax(float min, float max)
{
	channel->set3DMinMaxDistance(min,max);
}

void Sound::mute()
{
	channel->setMute(true);
}

void Sound::unMute()
{
	channel->setMute(false);
}

void Sound::setVolume(float volume)
{
	channel->setVolume(volume);
}